﻿using System;
using System.IO;

namespace TEST01
{
    class Program
    {
//1.在桌面创建名为：Demo 的文件夹，并添加两个子文件夹：TEST1 和 TEST2
//2.在TEST2中创建test2.txt文件并复制到TEST1.test1中
//3.使用流在test1写入StreamWriter写入数据： 道阻且难，行则将至。
//4.使用流在test2写入StreamWriter写入数据： 不忘初心，方得始终。
//5.在控制台输出这两句话。

        static void Main(string[] args)
        {
            //string path = @"C:\Users\Administrator\Desktop\Demo";
            //Directory.CreateDirectory(path);
            //DirectoryInfo di = new DirectoryInfo(path);
            //di.Create();

            //string path1 = @"C:\Users\Administrator\Desktop\Demo\TEST1";
            //Directory.CreateDirectory(path1);
            //DirectoryInfo di1 = new DirectoryInfo(path1);
            //di1.Create();
            //string path2 = @"C:\Users\Administrator\Desktop\Demo\TEST2";
            //Directory.CreateDirectory(path2);
            //DirectoryInfo di2 = new DirectoryInfo(path2);
            //di2.Create();

            //string test1 = @"C:\Users\Administrator\Desktop\Demo\TEST2\test2.txt";
            //FileInfo fi1 = new FileInfo(test1);
            //if (!fi1.Exists)
            //{
            //    fi1.Create();
            //}

            //fi1.CopyTo(@"C:\Users\Administrator\Desktop\Demo\TEST1\test1.txt");
            //string test2 = @"C:\Users\Administrator\Desktop\Demo\TEST1\test1.txt";



            //FileStream fs1 = new FileStream(test2, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
            //StreamWriter sw1 = new StreamWriter(fs1);
            //sw1.WriteLine("道阻且难，行则将至。");
            //sw1.Close();
            //fs1.Close();

            //FileStream fs2 = new FileStream(test1, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
            //StreamWriter sw2 = new StreamWriter(fs2);
            //sw2.WriteLine("不忘初心，方得始终。");
            //sw2.Close();
            //fs2.Close();

            //StreamReader sr1 = new StreamReader(fs1);
            //string str1 = sr1.ReadToEnd();
            //Console.Write(str1);

            //StreamReader sr2 = new StreamReader(fs2);
            //string str2 = sr2.ReadToEnd();
            //Console.Write(str2);
        }
    }
}
